package com.huobao.yunying.adapters;

import com.huobao.yunying.entity.FristPageList;
import com.huobao.yunying.utils.ImageUtils;
import com.huobao.yunying.utils.ImageUtils.OnImageLoadListener;
import com.huobao.zhangying.R;
import com.xrz.sxm.base.utils.ScreenUtil;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_FristPageListview extends QuickAdapter<FristPageList> {

	public Adapter_FristPageListview(Context context) {
		super(context, R.layout.item_fristpage_grid);
	}

	@Override
	protected void convert(BaseAdapterHelper helper, FristPageList arg1) {
		final ImageView imageView = helper.getView(R.id.imageview);
		TextView left = helper.getView(R.id.tv_1);
		TextView right = helper.getView(R.id.tv_2);
		left.setText(arg1.getAd_name());
		right.setText(arg1.getAd_remark());
		ImageUtils.loadimg(imageView, arg1.getAd_logo(), new OnImageLoadListener() {
			
			@Override
			public void onLoadSuccess(Drawable drawable) {
				int newHight = ScreenUtil.getInstant().getDisWidth(context) * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth();
				LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
				layoutParams.width = ScreenUtil.getInstant().getDisWidth(context);
				layoutParams.height = newHight;
				imageView.setLayoutParams(layoutParams);
				
				
			}
		});
	}

}
